<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="ko">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>배너관리 (메인)</title>
	<link type="text/css" href="../lib/calendar/themes/base/ui.all.css" rel="stylesheet" />
	<script src="../js/jquery.js" type="text/javascript"></script>
	<script src="../js/validator.js" type="text/javascript"></script>
	<script src="../lib/calendar/ui/ui.core.js" type="text/javascript"></script>
	<script src="../lib/calendar/ui/ui.datepicker-ko.js" type="text/javascript"></script>
	<script src="../lib/calendar/ui/ui.datepicker.js" type="text/javascript"></script>
	<script type="text/javascript">
		$(function() {
			//사용 비사용 체크
			var menu = new Array('banner_display_yn');
			var temp = new Array('${listMap.BANNER_DISPLAY_YN}');
			for (var i = 0; i < temp.length; i++) {
				if(temp[i] == 'Y'){
					$('#'+menu[i]+'1').attr("checked", true);
				}else{
					$('#'+menu[i]+'0').attr("checked", true);
				}
			} 
			
			//달력 로직
			var date = new Array('banner_display_sdt','banner_display_edt');
			for (var i = 0; i < date.length; i++) {
				$('#' + date[i]).datepicker({
					changeMonth: true,
					changeYear: true,
					yearRange: '2012:2020'
				});		
			}
		});	
	
		//check validity
	    function reg(frm)
	    {
			if (!checkAuth()) return false;
	    	if (!isTextValidate(frm.banner_title, "string", 0, "배너 이름"))			return false;
	    	if (!isTextValidate(frm.banner_url, "string", 0, "배너 주소"))				return false;
	    	if (!isTextValidate(frm.banner_desc, "string", 0, "배너 설명"))			return false;
	    	if (!isTextValidate(frm.banner_display_sdt, "string", 0, "게시 시작일"))	return false;
	    	if (!isTextValidate(frm.banner_display_edt, "string", 0, "게시 종료일"))	return false;
	    	if ($('input[name = new_file_relate_id]').val() != ''){ $('input[name = attached]').val('Y');}
	    	
			return true;
	    }
	    
	  	//삭제 확인 메시지
        function realDel()
        {
        	if (confirm("정말로 삭제하시겠습니까?"))
       		{
				var frm = document.forms["deleteFrm"];
				frm.submit();
       		}
        }
    </script>
</head>
<body>
		<!-- 본문 영역 -->
		<div id="contents">
			<!-- 제목 및 Location 영역 -->
			<div id="location">
				<h3 id="contentTitle"></h3>
				<div id="locationPath"></div>
			</div>
			<script type="text/javascript">
			// 현재 메뉴 경로를 설정한다.
			var pagePath = licationPth.split("_");
			var pathStr = "홈";
			for( var i=0; i < pagePath.length; i++ )
			{
				if (i+1 >= pagePath.length)
					pathStr += " &gt; <strong>" + pagePath[i] + "</strong>";
				else
					pathStr += " &gt; " + pagePath[i]
			}
			document.getElementById("contentTitle").innerHTML = pagePath[ pagePath.length - 1 ];
			document.getElementById("locationPath").innerHTML = pathStr;
			</script>

			<!-- 본문 내용 -->
			<div id="content">
				<form name="deleteFrm" method="post" action="../admin/main_bannermng_proc.do" onsubmit="return reg(this);">
				<input type="hidden" name="mode" value="delete" />
				<input type="hidden" name="banner_id" value="${listMap.BANNER_ID}" />
				<input type="hidden" name="file_relate_id" value="${fileListMap.FILE_RELATE_ID}" />
				<input type="hidden" name="file_path" value="${fileListMap.FILE_PATH}" />
				<input type="hidden" name="file_rename" value="${fileListMap.FILE_RENAME}" />
				<input type="hidden" name="file_job_id" value="banner" />
				<input type="hidden" name="file_id" value="${fileListMap.FILE_ID}" />
				</form>
				<form name="writeFrm" method="post" action="../admin/main_bannermng_proc.do" enctype="multipart/form-data" onsubmit="return reg(this);">
				<input type="hidden" name="mode" value="edit" />
				<input type="hidden" name="banner_id" value="${listMap.BANNER_ID}" />
				<input type="hidden" name="banner_sort" value="2" />
				<input type="hidden" name="file_relate_id" value="${fileListMap.FILE_RELATE_ID}" />
				<input type="hidden" name="file_path" value="${fileListMap.FILE_PATH}" />
				<input type="hidden" name="file_rename" value="${fileListMap.FILE_RENAME}" />
				<input type="hidden" name="attached" value="N" />
				<div class="ar">
					<span class="button btnProc01"><input type="submit" value="저장" /></span>
					<span class="button btnProc01"><a href="#" onclick="realDel();">삭제</a></span>
					<span class="button btnProc01"><a href="#" onclick="history.go(-1); return false;">취소</a></span>
				</div>
				<table cellspacing="0" cellpadding="0" border="0" class="tbl_type04">
					<colgroup>
						<col width="150px" />
					</colgroup>
					<thead>
						<th colspan="2">배너 수정 (메인)</th>
					</thead>
					<tbody>
						<tr>
							<th>파일 첨부</th>
							<td>
								<input type="file" name="new_file_relate_id"/>
								<a href="/common/download.do?fileid=${fileListMap.FILE_ID}&jobid=${fileListMap.FILE_JOB_ID}">
									${fileListMap.FILE_NAME}
								</a>
							</td>
						</tr>
						<tr>
							<th>배너 제목 (메인)</th>
							<td><input type="text" name="banner_title" size="20" maxlength="12" value="${listMap.BANNER_TITLE}"/> (12자리 이내)</td>
						</tr>
						<tr>
							<th>배너 주소 (메인)</th>
							<td><input type="text" name="banner_url" size="30" maxlength="50" value="${listMap.BANNER_URL}"/></td>
						</tr>
						<tr>
							<th>배너 설명 (메인)</th>
							<td><textarea rows="3" cols="40" name="banner_desc">${listMap.BANNER_DESC}</textarea></td>
						</tr>
						<tr>
							<th>표시 여부</th>
							<td>
								<input type="radio" name="banner_display_yn" id="banner_display_yn1" value="Y"/> 사용
								<input type="radio" name="banner_display_yn" id="banner_display_yn0" value="N"/> 미사용
							</td>
						</tr>
						<tr>
							<th>게시 날짜</th>
							<td>
								<input type="text" name="banner_display_sdt" id="banner_display_sdt" size="10" value="${listMap.BANNER_DISPLAY_SDT}">시작일
								<input type="text" name="banner_display_edt" id="banner_display_edt" size="10" value="${listMap.BANNER_DISPLAY_EDT}">종료일
							</td>
						</tr>
					</tbody>
				</table>
				</form>
			</div>
		</div>
</body>
</html>
